package com.p2p.service.operationsManagementService.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.p2p.common.base.RespResult;
import com.p2p.common.base.RespResultCode;
import com.p2p.entity.NewcomerStrategy;
import com.p2p.entity.SignStrategy;
import com.p2p.mapper.SignStrategyMapper;
import com.p2p.service.operationsManagementService.SignStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SignStrategyServiceImpl implements SignStrategyService {

    @Autowired
    private SignStrategyMapper signStrategyMapper;

    @Override
    public RespResult findSignStrategyList() {
        QueryWrapper<SignStrategy> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_deleted",0);
        List<SignStrategy> signStrategyList = signStrategyMapper.selectList(queryWrapper);
        if (signStrategyList.size() > 0){
            return RespResult.success(signStrategyList);
        }
        return RespResult.error(RespResultCode.ERR_PARAM_NOT_LEGAL.getCode(),RespResultCode.ERR_PARAM_NOT_LEGAL.getMessage(),null);
    }

    @Override
    public RespResult updateSignStrategy(SignStrategy signStrategy) {
        int i = signStrategyMapper.updateById(signStrategy);
        if (i > 0){
            return RespResult.success();
        }
        return RespResult.error(RespResultCode.ERR_PARAM_NOT_LEGAL.getCode(),RespResultCode.ERR_PARAM_NOT_LEGAL.getMessage(),null);
    }
}
